package com.edu.exam.entity.examination.paper;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.edu.exam.enums.SolutionType;
import com.edu.exam.enums.SolutionStatus;

import java.time.LocalDateTime;

/**
 * 冲突解决方案实体类
 *
 * <p>冲突解决方案实体，记录监考安排冲突的解决方案和执行情况。
 * 支持多种解决方案类型和执行状态跟踪。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ConflictSolution {

    /**
     * 解决方案ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long solutionId;

    /**
     * 冲突记录ID
     */
    @Column(name = "conflict_id", nullable = false)
    private Long conflictId;

    /**
     * 解决方案类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "solution_type", length = 20, nullable = false)
    private SolutionType solutionType;

    /**
     * 解决方案描述
     */
    @Column(name = "solution_description", columnDefinition = "TEXT")
    private String solutionDescription;

    /**
     * 解决方案状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "solution_status", length = 20, nullable = false)
    private SolutionStatus solutionStatus;

    /**
     * 执行时间
     */
    @Column(name = "executed_time")
    private LocalDateTime executedTime;

    /**
     * 执行人ID
     */
    @Column(name = "executed_by", length = 32)
    private String executedBy;

    /**
     * 执行人姓名
     */
    @Column(name = "executed_by_name", length = 50)
    private String executedByName;

    /**
     * 执行结果
     */
    @Column(name = "execution_result", length = 500)
    private String executionResult;

    /**
     * 预期效果
     */
    @Column(name = "expected_effect", length = 500)
    private String expectedEffect;

    /**
     * 实际效果
     */
    @Column(name = "actual_effect", length = 500)
    private String actualEffect;

    /**
     * 解决优先级
     */
    @Column(name = "solution_priority")
    private Integer solutionPriority;

    /**
     * 解决成本
     */
    @Column(name = "solution_cost")
    private Double solutionCost;

    /**
     * 风险评估
     */
    @Column(name = "risk_assessment", length = 300)
    private String riskAssessment;

    /**
     * 后续跟进要求
     */
    @Column(name = "follow_up_requirements", length = 500)
    private String followUpRequirements;

    /**
     * 创建人ID
     */
    @Column(name = "created_by", length = 32, nullable = false)
    private String createdBy;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 冲突记录关联
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "conflict_id", insertable = false, updatable = false)
    private AssignmentConflict conflict;
}